
const inputString = `
Host: www.bilibili.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Referer: https://www.bilibili.com/
Connection: keep-alive
Cookie: buvid3=F1E4D686-AC5C-65D1-EB95-3344A7F7771822693infoc; b_nut=1705234422; i-wanna-go-back=-1; b_ut=7; b_lsid=B149A10E7_18D07E45E1B; _uuid=F7664B91-3514-7963-9106B-C8B3428976E123338infoc; enable_web_push=DISABLE; header_theme_version=undefined; buvid_fp=a98cd5ab4eea6ee6b09ff7af58fa0bad; buvid4=0376D52F-C693-A639-63AA-5034546EF4B324251-024011412-DmNJFfDhW%2FJvRA%2B0atSuxA%3D%3D; home_feed_column=5; browser_resolution=1440-790; CURRENT_FNVAL=4048; sid=o5ejfgrn; rpdid=|(umu|Rum~u|0J'u~|lkJRRJk; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDU0OTM2MzUsImlhdCI6MTcwNTIzNDM3NSwicGx0IjotMX0.wXe1k2Wb6vKdl9qYKJ3L0H_qtEt7NbZqdWSFGyoi1Hc; bili_ticket_expires=1705493575
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Pragma: no-cache
Cache-Control: no-cache
TE: trailers
`;


const inputString2 = `
authority:api.bilibili.com
accept:*/*
accept-language:zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7
cache-control:no-cache
content-type:application/x-www-form-urlencoded
cookie:buvid3=44EC9AF3-580F-D42E-7AD8-4276C4596DDE77714infoc; b_nut=1683860177; _uuid=F4B9101022-47B5-68101-34B7-1D35D991BA8578052infoc; FEED_LIVE_VERSION=V8; header_theme_version=CLOSE; buvid4=417C1327-C2C2-59C2-F598-11F84211F87779501-023051210-ITAnNTZexY%2FYGJ2IUbpHYw%3D%3D; rpdid=|(ummY|RR)~u0J'uY)~mR)~lk; is-2022-channel=1; fingerprint=6ea836dc9c3be1ad9623337f314e20cf; buvid_fp_plain=undefined; buvid_fp=6ea836dc9c3be1ad9623337f314e20cf; CURRENT_BLACKGAP=0; hit-new-style-dyn=1; bsource=search_baidu; enable_web_push=DISABLE; hit-dyn-v2=1; PVID=1; home_feed_column=5; CURRENT_FNVAL=4048; browser_resolution=1439-754; b_lsid=BD8B1732_18CE3F56D43; SESSDATA=3a139032%2C1720183582%2C91bd5%2A11CjDcykDnbk3PmvyNqJe-GG3wxKGWiBmvTlGsSioibD7FlOKlKWPv8LEC3weCnq-_o3ISVjZQNVNRUG42N0w3dnRtcldvWG1Dcldmb1ZSS1BqeWtyc3NqN1BzYWFtVE9hTXJaQTBzX2pwYlliLW0tTzhnbEpfVmdwZWpVUHhwM21ndU1ITkNmNndnIIEC; bili_jct=78ae0a55f4a0916fdaf507ffb7aa387c; DedeUserID=523726062; DedeUserID__ckMd5=37372de227757075; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDQ4OTA3OTQsImlhdCI6MTcwNDYzMTUzNCwicGx0IjotMX0.JNqpOxpV8hRBHlV0e1bda7KlLLDcnyTzp9Kp6JiPRl0; bili_ticket_expires=1704890734; bp_video_offset_523726062=883870773101461603; sid=7wh8mukc
origin:https://www.bilibili.com
pragma:no-cache
referer:https://www.bilibili.com/video/BV1BG4y1Z79U/?spm_id_from=333.337.search-card.all.click&vd_source=bdc6dd1ddbf9abb5085821f4be4e9863
sec-ch-ua:"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"
sec-ch-ua-mobile:?0
sec-ch-ua-platform:"macOS"
sec-fetch-dest:empty
sec-fetch-mode:cors
sec-fetch-site:same-site
user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
`;

// 将数组中的对象合并成一个对象
function getHeaders(){

    // 使用正则表达式匹配每一行的键值对，并将其转换为 JSON 对象
    const keyValuePairs = inputString.split('\n').filter(Boolean).map(line => {
        const [key, value] = line.split(': ').map(str => str.trim());
        return { [key]: value };
    });
    return Object.assign({}, ...keyValuePairs);

}

const bili_headers = getHeaders(inputString);
const bili_login_headers = getHeaders(inputString2);


module.exports = {
    bili_headers,
    bili_login_headers,
};


